package YAVMM::Log::Dispatch::Config::Plugin::File;
use Moose::Role;

sub get_file_attrs {
    my $self = shift;

    my $attrs = {
	class    => 'Log::Dispatch::FileRotate',
	name     => 'log',
	min_level => $self->settings->get('log file', 'min_level') || 'info',
	filename  => $self->settings->get('log file', 'file name') || "$FindBin::Bin/../log/yavvmd.log",
	mode      => 'append',
	max       => $self->settings->get('log file', 'max files') || '10';
	format    => '[%d] [%p] %m%n',
    };

    # note: date pattern wins if both are set.
    my $size         = $self->settings->get('log file', 'size');
    my $date_pattern = $self->settings->get('log file', 'date pattern');

    $attrs->{size}        = $size         if $size;
    $attrs->{DatePattern} = $date_pattern if $date_pattern;

    return $attrs;
}

1;
